package chain.aimpl;

import java.util.ArrayList;
import java.util.List;

public class Client {
    public static void main(String[] args) {
        System.out.println(getNames(20));

        System.out.println(getNames(500));

        System.out.println(getNames(1000));

        System.out.println(getNames(30000));
    }

    private static List<String> getNames(int money) {
        AbstractHandler[] abstractHandler = new AbstractHandler[]{new Employee(),new Leader(), new Boss()};

        for (int i = 0; i < abstractHandler.length; i++) {
            if (i + 1 >= abstractHandler.length) {
                break;
            }
            abstractHandler[i].setNextHandler(abstractHandler[i + 1]);
        }

        List<String> names = new ArrayList<>();
        abstractHandler[0].doChain(money, names);
        return names;
    }
}
